<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../common/jsp/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>基础数据管理-客户管理</title>
<%@ include file="../../common/jsp/config.jsp"%>
<%@ include file="../../common/jsp/pageable.jsp"%>
<script type="text/javascript" src="common/js/jquery/chinaArea/jquery.fillOptions.js"></script>
<script type="text/javascript">
	function deleteItem(id){
		if (window.confirm('确定要删除这个客户吗?')==true) {
			$("#customerList").attr("action", "deleteCustomer.action?customerId=" + id);
	    	$("#customerList").submit();
		}
	}
    /**
     * Callback function that displays the content.
     *
     * Gets called every time the user clicks on a pagination link.
     *
     * @param {int} page_index New Page index
     * @param {jQuery} jq the container with the pagination links as a jQuery object
     */
    function pageselectCallback(page_index, jq){
    	var oldPageIndex = $("#pageInfo_pageIndex").val();
        if (page_index != oldPageIndex) {
        	$("#pageInfo_pageIndex").val(page_index);
        	$("#customerList").submit();
        }
        return false;
    }

     function querySubmit() {
    	 $("#pageInfo_pageIndex").val("0");
    	 $("#customerList").submit();
    	 return false;
     }

     function editCustomer(id) {
     	alertDialog(700, 500, "editCustomer.action?customerId=" + id, 
    	    	function (result) {
    	    		if (result == DIALOG_RESULT_TYPE_SUCCESS) {
    	    			alert("修改成功");
    	    			$("#customerList").submit();
    	    		}
    	    	});
     }

     function addCustomer() {
     	alertDialog(700, 500, "addCustomer.action", 
    	    	function (result) {
    	    		if (result == DIALOG_RESULT_TYPE_SUCCESS) {
    	    			alert("添加成功");
    	    			$("#customerList").submit();
    	    		}
    	    	});
     }

     function viewCustomer(id) {
      	alertDialog(700, 500, "viewCustomer.action?customerId=" + id);
     }

  	$(document).ready(function() {
		$("#condition_category").bind("change", function() {
			var parentId = $(this).val();
			$("#sencond_category").fillOptions(
					"queryMaterialsCategoryJOSN.action?categoryId=" + parentId,
					{datatype:"json",textfield:"name",valuefiled:"id",jsonData:"categoryList"});
		});
	});
</script>
</head>
<body>
    <div class="subnav" align="left">
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">基础数据管理</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">客户管理</span></td>
		  </tr>
		</table>
      </div>
<table width="99%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="right"><input type="button" value="添加新客户" onclick='addCustomer()'  class="inputlong" /></td>
  </tr>
</table>
<s:actionerror cssStyle="color:red"/>
<div class="main_1">
  <s:form action="customerList">
  <s:hidden id="pageInfo_pageIndex" name="pageInfo.pageIndex" />
  <table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="#D3DEEF">
    <tr align="left">
      <td bgcolor="#FFFFFF">
      	<table width="100%" border="0" cellspacing="1" cellpadding="2">
        <tr>
    	  <td width="10%" align="right">客户名称</td>
    	  <td width="20%">
            <s:textfield name="condition.name" size="20" />
          </td>
          <td align="right">
            <input type="button" value="查询" class="input1" onclick="querySubmit()" />
          </td>
        </tr>
      </table>
      </td>
    </tr>
  </table>
  </s:form>
</div>
<div class="ksglxx2">

  <table width="100%" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <tr class="ksglxx2bg">
           <th width="20%" align="left">客户名称</th>
           <th width="25%" align="left">地区</th>
           <th width="20%" align="left">产品分类</th>
           <th width="17%" align="left">地址</th>
           <th width="18%" align="left"></th>
        </tr>
        <s:iterator value="customerList" id="customer" status="st">
          <s:if test="#st.Odd">
            <tr class="odd">
          </s:if>
          <s:else>
            <tr class="even">
          </s:else>
              <td><s:property value="#customer.name" /></td>
              <td><s:property value="#customer.area" /></td>
              <td><s:property value="#customer.conditionCategory" /></td>
              <td><s:property value="#customer.address" /></td>
              <td align="center">
                <a class="b" href='javascript:viewCustomer(<s:property value="#customer.id" />)'>
                  <img src="common/images/view.gif" alt="Edit" border="0" align="absmiddle" /></a>&nbsp;&nbsp;
                <a class="b" href='javascript:editCustomer(<s:property value="#customer.id" />)'>
                  <img src="common/images/Edit.gif" alt="Edit" border="0" align="absmiddle" /></a>&nbsp;&nbsp;
                <a class="b" href='javascript:deleteItem(<s:property value="#customer.id" />)'>
                  <img src="common/images/Delete.gif" alt="Delete" border="0" align="absmiddle" /></a>
         	  </td>
            </tr>
         </s:iterator>
        </table>
		
		<!--分页开始-->
		<div style="float:right;">
			<br style="clear:both;" /> 
			<div id="Pagination"></div> 
		</div>
		<!--分页结束-->

</div>
</body>
</html>
